let app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {

    matchListData:[],
 
    autoplay: true,
        typeValue: null,
        showRightToast: false,
        changeImg: false,
        show: true,
        
        played: false,
        //滑动触点开始的时候
        startPoint: 0,
        currentImageIndex: 0,
        swiperH:'',//swiper高度
         nowIdx:0,//当前swiper索引
         rent:0,
         city_hidden:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    
    this.setData({
      domain:app.globalData.domain,
        width:app.globalData.windowWidth,
      height:app.globalData.windowHeight,
      statusBarHeight:app.globalData.statusBarHeight,
      navHeight:app.globalData.navHeight,
      marginTop:app.globalData.navTitleTop
    })
    
  },
  getMatch: function (message){
    wx.showLoading({							
      title: message,
    })
    var that = this;
    wx.request({
      url: app.globalData.domain+'wechat/face/getMatch',
      success:function(res){
        wx.hideLoading();
        console.log(res.data);
        var contentlist = res.data;
        that.setData({
          matchListData:contentlist.match_list,
          //swiperList: contentlist.swiperList
        })
        ////console.log(that.data.matchListData)
      },
      fail:function(){
      }
    })
  },
  getHeight:function(e){
    var winWid = wx.getSystemInfoSync().windowWidth;//获取当前屏幕的宽度
    var imgh = e.detail.height;//图片高度
    var imgw = e.detail.width;
    var sH = winWid * imgh / imgw + "px"
    this.setData({
        swiperH: sH//设置高度
    })
},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getMatch('正在加载数据...')
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  swiperChange:function(e){
    // console.log(e.detail.current);
       this.setData({
           nowIdx: e.detail.current
       })
   },
   fn:function(e){
     congsole.log(e);
   },
   gotoList:function(e){
    console.log(e);
    var active=e.currentTarget.dataset.active;
    var matchid=e.currentTarget.dataset.matchid;
    var matchname=e.currentTarget.dataset.matchname;
  
      wx.navigateTo({
         url: 'list?match_id='+matchid+'&matchname='+matchname,
      })
    
  
},
searchNo:function(e){
  console.log(e);  
  var matchid=e.currentTarget.dataset.matchid;
  var matchname=e.currentTarget.dataset.matchname;

    wx.navigateTo({
       url: 'matchNo?match_id='+matchid+'&matchname='+matchname,
    })
  

},
score:function(e){
  console.log(e);  
  var matchid=e.currentTarget.dataset.matchid;
  var matchname=e.currentTarget.dataset.matchname;

    wx.navigateTo({
       url: 'Score?match_id='+matchid+'&matchname='+matchname,
    })
  

},
   goto:function(e){
       console.log(e);
       var active=e.currentTarget.dataset.active;
       var url=e.currentTarget.dataset.url;
       if(active=='index'){
           if(url!="#"){
         wx.reLaunch({
           url: url,
         })
        }
       }else{
         if(url!="#"){
         wx.navigateTo({
            url: url,
         })
       }
     }
   }
})